package cn.stylefeng.guns.modular.business.frequency.cmcity.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.cmcity.service.CmCityService;
import cn.stylefeng.guns.modular.business.frequency.cmcity.model.param.CmCityParam;

import javax.annotation.Resource;

/**
 * cm_city 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:17
 */
@RestController
public class CmCityController {

    @Resource
    private CmCityService cmCityService;

    /**
     * 分页查询cm_city
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmCity/page")
    @BusinessLog(title = "cm_city_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CmCityParam cmCityParam) {
        return new SuccessResponseData(cmCityService.page(cmCityParam));
    }

    /**
     * 获取全部cm_city
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmCity/list")
    @BusinessLog(title = "cm_city_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CmCityParam cmCityParam) {
        return new SuccessResponseData(cmCityService.list(cmCityParam));
    }

    /**
     * 查看详情cm_city
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmCity/detail")
    @BusinessLog(title = "cm_city_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CmCityParam.detail.class) CmCityParam cmCityParam) {
        return new SuccessResponseData(cmCityService.detail(cmCityParam));
    }

    /**
     * 添加cm_city
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmCity/add")
    @BusinessLog(title = "cm_city_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CmCityParam.add.class) CmCityParam cmCityParam) {
        cmCityService.add(cmCityParam);
        return new SuccessResponseData();
    }

    /**
     * 删除cm_city
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmCity/delete")
    @BusinessLog(title = "cm_city_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CmCityParam.delete.class) CmCityParam cmCityParam) {
        cmCityService.delete(cmCityParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑cm_city
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmCity/edit")
    @BusinessLog(title = "cm_city_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CmCityParam.edit.class) CmCityParam cmCityParam) {
        cmCityService.edit(cmCityParam);
        return new SuccessResponseData();
    }


}
